<?php

/**
 * Description of Report_withdrawal_ewalletController
 *
 * @author TEJO MURTI
 */
class Report_withdrawal_ewalletController extends AdminController {

    public function actionView() {
	$session=Yii::app()->session;

	$model=new sys_ewallet_withdrawal('search_withdrawal_ewallet');
	$model->unsetAttributes();
	if(isset($_GET['sys_ewallet_withdrawal']))
	{
		$model->attributes=$_GET['sys_ewallet_withdrawal'];
	} 

	 //SET TYPE DOWNLOAD FILE 
       if(isset($_POST['button']))
       {

           $dataProvider=$model->findAll($session['data_export']->criteria);
           $button=$_POST['button'];
           foreach($button AS $key=>$val)
           {
               $type=$key;
           }

           //$dataProvider=$model_serial_buyer->search_serial_report();
           if($dataProvider)
           {
               foreach($dataProvider AS $val)
               {
		  $filter_data[]=array(
                       'MID'=>$val->ewallet_withdrawal_to_network->network_mid,
                       'Member Name'=>$val->ewallet_withdrawal_to_network->rel_network_to_member->member_name,
                       'Bank Name'=>$val->ewallet_withdrawal_to_network->rel_network_to_member->rel_member_to_ref_bank->bank_name,
                       'Bank Account No'=>$val->ewallet_withdrawal_to_network->rel_network_to_member->member_bank_account_no,
                       'Ewallet Withdrawal Value'=>$val->ewallet_withdrawal_value,
                       'Tanggal'=>$val->ewallet_withdrawal_datetime,
                   );

               }
           }
                if(isset($filter_data) AND is_array($filter_data))
                {
                   switch ($type)
                   {
                        case 'xls':
                            ExcelExporterCustom::sendAsXLS($filename='Data Report Withdrawal Ewallet', $filter_data, 'Withdrawal Ewallet', $header = true);
                        break;
          default:
                            die('Please make sure your choice. ');
                        break;
                   }
                }




       }

        $this->render('view', 
		array(
		'model' => $model,
            ));
    }


}

?>
